import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/28 20:31
 */

public class Solution {
    public int[] singleNumber(int[] nums) {
        int x = 0;
        for (int i : nums)
            x ^= i;//先得到两个只出现一次的数字的异或结果

        //找到x中最右边的1
        int mark = 1;
        while ((x & mark) == 0)
            mark <<= 1;

        //根据mark将数组中的数分成两组，并分别异或
        int num1 = 0, num2 = 0;
        for (int i : nums) {
            if ((i & mark) == 0) num1 ^= i;
            else num2 ^= i;
        }
        return new int[]{num1, num2};
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            int[] ret = solution.singleNumber(nums);
            System.out.println(Arrays.toString(ret));
        }
    }
}